package com.selftest.exception;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

//@ControllerAdvice
public class TestExceptionHandler {

    @ExceptionHandler(value = ArithmeticException.class)
    public ResponseEntity<String> handleException(ArithmeticException ex) {
        System.out.println("全局异常处理！！！");
        // 异常处理逻辑
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("发生异常：" + ex.getMessage());
    }
}
